package com.leecode;

public class OrMinRevertMain {
	public static void main(String[] args) {
//		new OrMinRevertMain().minFlips(10, 9, 1);
		new OrMinRevertMain().minFlips(2, 6, 5);
	}

	public int minFlips(int a, int b, int c) {
		int sum=0;

		do{
			int la=a%2;
			int lb=b%2;
			int lc=c%2;
			if(lc==1&&la==0&&lb==0){
				++sum;
			}else if(lc==0&&la==1&&lb==1){
				sum+=2;
			}else if(lc==0&&(la==1||lb==1)){
				++sum;
			}
			a=a>>1;
			b=b>>1;
			c=c>>1;
		}while(a!=0||b!=0||c!=0);

		return sum;
	}
}
